<?php

namespace app\adminapi\controller\system;

use app\adminapi\service\SysRoleMenuService;
use app\adminapi\validate\SysRoleMenuValidate;
use app\common\controller\BaseAdminController;

class SysRoleMenuController extends BaseAdminController
{
    public array $notNeedLogin = [];

    /**
     * @title   新增角色菜单
     * @businessType    INSERT
     */
    public function insert()
    {
        $params = (new SysRoleMenuValidate())->post()->goCheck('insert');
        (new SysRoleMenuService())->addSysRoleMenu($params);
        return app('json')->success();
    }

    public function query()
    {
        $params = (new SysRoleMenuValidate())->get()->goCheck('query');
        $result = (new SysRoleMenuService())->getSysRoleMenuByRoleId($params['roleId']);
        return app('json')->successWithData($result);
    }

    /**
     * @title   更新角色菜单
     * @businessType    UPDATE
     */
    public function update()
    {
        $params = (new SysRoleMenuValidate())->put()->goCheck('update');
        $result = (new SysRoleMenuService())->updateSysRoleMenu($params);
        return app('json')->successWithData($result);
    }
}